package cn.tedu.egweibo0416.base.interceptor;

import cn.tedu.egweibo0416.pojo.vo.UserVO;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class MyInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session = request.getSession();
        UserVO userVO = (UserVO)session.getAttribute("user");
        if(userVO != null){
            return true;
        }
        response.sendRedirect("/login.html");
        return false;
    }
}
